# configure.ac  
AC_PREREQ([2.69])
AC_INIT([mmv], [1.0.0], [lijaingjun931026@outlook.com]) 
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AC_CONFIG_SRCDIR([mgnotify/src/mgnotify.cpp]) 
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])
 
# Check for C++ compiler 
AC_PROG_CXX 
AX_CXX_COMPILE_STDCXX([17], [ext], [mandatory])
AC_PROG_CC 
AM_PROG_AR  # 关键修复点 
AC_LANG([C++])
 
# Check for required programs 
AC_PROG_INSTALL 
AC_PROG_MAKE_SET 
LT_INIT([shared])  # Initialize libtool for shared libraries 
 
# Check for required libraries (add as needed)
# PKG_CHECK_MODULES([DEPENDENCY], [some-dependency >= 1.0])

# 检查 Qt5
PKG_CHECK_MODULES([QT], [Qt5Gui >= 5.15.0], [
    AC_SUBST([QT_CPPFLAGS])     # 包含路径
    AC_SUBST([QT_LIBS])         # 链接库 
], [
    AC_MSG_ERROR([Qt5 not found!])
])
 
# Enable debug if needed 
AC_ARG_ENABLE([debug],
    [AS_HELP_STRING([--enable-debug],
        [Enable debug mode (default=no)])],
    [CXXFLAGS="$CXXFLAGS -g -O0"],
    [CXXFLAGS="$CXXFLAGS -O2"])

# 添加 --enable-example14 选项 
AC_ARG_ENABLE([example14],
    [AS_HELP_STRING([--enable-example14],
        [Build example14 (default=no)])],
    [enable_example14=$enableval],
    [enable_example14=no])
AM_CONDITIONAL([BUILD_EXAMPLE14], [test "x$enable_example14" = "xyes"])

AC_MSG_CHECKING([whether to build example14])
if test "x$enable_example14" = "xyes"; then 
    AC_MSG_RESULT([yes])
    AC_DEFINE([HAVE_EXAMPLE14], [1], [Define if example14 is enabled])
else 
    AC_MSG_RESULT([no])
fi 
 
# Output files 
AC_CONFIG_FILES([
    Makefile 
    mgnotify/Makefile 
    mgnotify/mgnotify.pc
    examples/Makefile 
    examples/example1/Makefile 
    examples/example2/Makefile 
    examples/example3/Makefile 
    examples/example4/Makefile 
    examples/example5/Makefile 
    examples/example6/Makefile 
    examples/example7/Makefile 
    examples/example8/Makefile 
    examples/example9/Makefile 
    examples/example10/Makefile 
    examples/example11/Makefile 
    examples/example12/Makefile 
    examples/example13/Makefile 
    examples/example14/Makefile 
])
AC_OUTPUT 